package com.itheima;

import java.util.HashMap;
import java.util.Map;

public class MapPractice {
    public static void main(String[] args) {
        //创建一个HashMap对象
        Map<String, String> data = new HashMap<>();
        data.put("小王", "A");
        data.put("小李", "B");
        data.put("小张", "C");
        data.put("小王1", "C");
        data.put("小王2", "A");
        data.put("小王3", "B");
        data.put("小王4", "A");
        data.put("小王5", "C");
        data.put("小王6", "A");
        count(data);
    }

    public static void count(Map<String,String> map){
        Map<String,Integer> mapA = new HashMap<>();
        Map<String,Integer> mapB = new HashMap<>();
        Map<String,Integer> mapC = new HashMap<>();
        Map<String,Integer> mapD = new HashMap<>();
        Integer valueA=0;
        Integer valueB=0;
        Integer valueC=0;
        Integer valueD=0;
        for (Map.Entry<String,String> entry:map.entrySet()){
            if(entry.getValue().equals("A")){
                mapA.put(entry.getValue(),++valueA);
            }
            if(entry.getValue().equals("B")){
                mapB.put(entry.getValue(),++valueB);
            }
            if(entry.getValue().equals("C")){
                mapC.put(entry.getValue(),++valueC);
            }
            if(entry.getValue().equals("D")){
                mapD.put(entry.getValue(),++valueD);
            }
        }
        for (Map.Entry<String,Integer> entry:mapA.entrySet()){
            System.out.println(entry.getKey()+","+entry.getValue());
        }
        for (Map.Entry<String,Integer> entry:mapB.entrySet()){
            System.out.println(entry.getKey()+","+entry.getValue());
        }
        for (Map.Entry<String,Integer> entry:mapC.entrySet()){
            System.out.println(entry.getKey()+","+entry.getValue());
        }
        for (Map.Entry<String,Integer> entry:mapD.entrySet()){
            System.out.println(entry.getKey()+","+entry.getValue());
        }
    }
}